package api.ttbanner;

import android.app.Activity;
import android.content.Context;
import android.view.ViewGroup;

import androidx.fragment.app.FragmentActivity;

import java.lang.ref.SoftReference;

import api.ttfeed.Express_API_TT;
import api.ttfullvideo.FullVideo_API_TT;

public abstract class Banner_API_TT {
    public static String clazz = "com.dotools.toutiaolibrary.TT_Banner";
    private static SoftReference<Banner_API_TT> sf;
    public abstract void bindDislike(FragmentActivity activity, ViewGroup container);
    public synchronized static Banner_API_TT getInstance() {

        if (sf == null || sf.get() == null) {
            Object o = null;
            try {
                o = Class.forName(clazz).newInstance();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            if (o != null) {
                sf = new SoftReference<>((Banner_API_TT) o);
                return (Banner_API_TT) o;
            }
        }
        return sf == null ? null : sf.get();
    }

    //downloadMode是下载提示弹窗 1是显示

    public abstract void loadTTBanner(Context context, String appid, String adposid, int expressViewWidth,
                                      int expressViewHeight,int downloadMode, boolean isDebug,
                                      final ViewGroup container,int count, final TTBannerListener listener);
    public abstract void expressDestroy();
    public interface TTBannerListener {
        void onLoad(int size);
        void onObClicked(int type);
        void onObShow(int type);
        void onRenderFail(String msg, int code);
        void onRenderSuccess();
        void onError(int code, String message);
    }
}
